//
//  KPaymentRequest.m
//  Peanut
//
//  Created by Jim huang on 2018/4/11.
//  Copyright © 2018年 Jim_Peanut. All rights reserved.
//

#import "KPaymentRequest.h"
#import "KPaymentAPI.h"

@implementation KPaymentRequest

//添加请求头
-(NSDictionary<NSString *,NSString *> *)requestHeaderFieldValueDictionary{
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    
    if (![[KuserInfo shareInstance].userModel.sid isNotBlank]) {

        return nil;
    }
    [dic setValue:[KuserInfo shareInstance].userModel.sid forKey:@"sid"];
    
    return dic;
}



/**
 支付请求
 
 @param amount 金额  bizType=3时需要传，其它传空
 @param bizType     业务类型  1=会员充值，2=订单支付,3=花生宝充值，4=手机公排，5=汽车公排
 @param entityid 业务id  当bizType=1时传会员等id，当bizType=2时传商品id，bizType=3时传空
 @param recommendCod 推荐码  bizType=5或4传
 @param type     支付类型 1=支付宝，2=微信，3=银行卡
 */
-(instancetype)initPaymentWithAmount:(NSString *)amount bizType:(NSString *)bizType entityid:(NSString *)entityid type:(NSString *)type recommendCod:(NSString *)recommendCod{
    
    if (self = [super initPOSTWithRequestUrl:KPaymentURL]) {
        
        [self.paramsDic setValue:amount forKey:@"amount"];
        [self.paramsDic setValue:bizType forKey:@"bizType"];
        [self.paramsDic setValue:entityid forKey:@"entityid"];
        [self.paramsDic setValue:recommendCod forKey:@"recommendCod"];
        [self.paramsDic setValue:type forKey:@"type"];

    }
    return self;
}

/**
 乐多余额支付
 
 @param soEntityId 订单id
 @param transactionPassword 支付密码

 */
-(instancetype)initPaymentLDFreePayWithSoEntityId:(NSString *)soEntityId transactionPassword:(NSString *)transactionPassword{
    if (self = [super initPOSTWithRequestUrl:KPaymentLDFreePayURL]) {
        
        [self.paramsDic setValue:soEntityId forKey:@"soEntityId"];
        [self.paramsDic setValue:transactionPassword forKey:@"transactionPassword"];

    }
    return self;
    
    
}

/**
 余额支付
 
 @param soEntityId 订单id
 @param transactionPassword 支付密码
 */
-(instancetype)initPaymentAmountPayWithSoEntityId:(NSString *)soEntityId transactionPassword:(NSString *)transactionPassword{
    if (self = [super initPOSTWithRequestUrl:KPaymentAmountPayURL]) {
        
        [self.paramsDic setValue:soEntityId forKey:@"soEntityId"];
        [self.paramsDic setValue:transactionPassword forKey:@"transactionPassword"];
        
    }
    return self;
    
    
}

@end
